package cn.zhizihua.domain.query;

import cn.zhizihua.domain.po.Business;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import lombok.Data;

/*
BusinessQuery extends BaseQuery
模块条件                 基础(分页)条件
即拥有了分页条件  也有自己的搜索条件

select * from t_business
where 1=1 and businessName like concat('%',?,'%')
limit ?,?

 */
@Data
public class BusinessQuery extends BaseQuery {

    private String businessName; //商家名称模糊搜索的条件
    private String businessAddress;//商家地址模糊搜索的条件

    @Override
    public Wrapper getQueryWrapper() {
        QueryWrapper<Business> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(businessName)){
            queryWrapper.like("businessName",businessName);
        }
        if (StringUtils.isNotEmpty(businessAddress)){
            queryWrapper.like("businessAddress",businessAddress);
        }
        queryWrapper.orderByDesc("businessId");
        return queryWrapper;
    }
}
